﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace DoAnB
{
    public partial class frmGopBan : Form
    {
        public string bandagop { get; set; }
        public frmGopBan()
        {
            InitializeComponent();
            DataView view = new DataView(Main.datatbTam);

            DataTable dt = view.ToTable(true, "TenBan");

            comboBox2.DataSource = dt;
            comboBox2.DisplayMember = "TenBan";
            DataRow x = dt.NewRow();

            foreach (DataRow i in dt.Rows)
            {
                if (i["TenBan"].ToString() == Main.banguitoisubform.ToString())
                    x = i;
            }
            dt.Rows.Remove(x);
            this.Text = "Gộp '" + Main.banguitoisubform.ToString() + "'";
           
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            if (Main.banguitoisubform == comboBox2.Text)
                MessageBox.Show("2 bàn giống nhau!", "Thông báo", MessageBoxButtons.OK);
            else {
                foreach (DataRow var in Main.datatbTam.Rows)
                {
                    if (var[0].ToString() == Main.banguitoisubform)
                        var[0] = comboBox2.Text;
                }
                bandagop = comboBox2.Text;

                DialogResult = DialogResult.OK;
            }
        }
    }
}
